﻿//Object Constructor invocation pattern
app.controller('MessageController', function ($scope, MessageService) {
    MessageService.getMessages().then(function (data) {
        $scope.chatArray = data;
    }, function () {
        //some error
    });

    $scope.addMessage = function () {
        MessageService.addMessage($scope.name, $scope.message);
    };

    $scope.removeMessage = function (message) {
        MessageService.removeMessage(message);
        //$scope.chatArray.splice($scope.chatArray.indexOf(message), 1);
    };
});